home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / ibus / setup / engineabout.py next >
Text File  |  2009-11-05  |  4KB  |  103 lines

  1. # vim:set et sts=4 sw=4:
  2. #
  3. # ibus - The Input Bus
  4. #
  5. # Copyright (c) 2007-2008 Huang Peng <shawn.p.huang@gmail.com>
  6. #
  7. # This library is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU Lesser General Public
  9. # License as published by the Free Software Foundation; either
  10. # version 2 of the License, or (at your option) any later version.
  11. #
  12. # This library is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Lesser General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Lesser General Public
  18. # License along with this program; if not, write to the
  19. # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  20. # Boston, MA  02111-1307  USA
  21.  
  22. import gtk
  23. from gtk import gdk
  24. import pango
  25. import ibus
  26.  
  27. from gettext import dgettext
  28. _  = lambda a : dgettext("ibus", a)
  29. N_ = lambda a : a
  30.  
  31. class EngineAbout(gtk.Dialog):
  32.     def __init__(self, enginedesc):
  33.         self.__engine_desc = enginedesc
  34.         super(EngineAbout, self).__init__(_("About"), None, gtk.DIALOG_MODAL, (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
  35.  
  36.         self.__init_ui()
  37.  
  38.     def __init_ui(self):
  39.         self.set_icon_name("gtk-about")
  40.         sw = gtk.ScrolledWindow()
  41.         sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
  42.         sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
  43.         self.__text_view = gtk.TextView()
  44.         self.__text_view.set_size_request(400, 400)
  45.         self.__text_view.set_editable(False)
  46.         sw.add(self.__text_view)
  47.         sw.show_all()
  48.         self.vbox.pack_start(sw)
  49.  
  50.         self.__fill_text_view()
  51.  
  52.     def __fill_text_view(self):
  53.         text_buffer = self.__text_view.get_buffer()
  54.         self.__create_tags(text_buffer)
  55.         
  56.         iter = text_buffer.get_iter_at_offset(0)
  57.         text_buffer.insert_with_tags_by_name(iter, "\n ",
  58.                                              "left_margin_16")
  59.         text_buffer.insert_pixbuf(iter, self.__load_icon(self.__engine_desc.icon))
  60.         text_buffer.insert_with_tags_by_name(iter, "\n%s\n" % self.__engine_desc.longname,
  61.                                              "heading", "left_margin_16")
  62.         text_buffer.insert_with_tags_by_name(iter, _("Language: %s\n") % ibus.get_language_name(self.__engine_desc.language),
  63.                                             "small", "bold", "left_margin_16")
  64.         text_buffer.insert_with_tags_by_name(iter, _("Keyboard layout: %s\n") % self.__engine_desc.layout,
  65.                                             "small", "bold", "left_margin_16")
  66.         text_buffer.insert_with_tags_by_name(iter, _("Author: %s\n") % self.__engine_desc.author,
  67.                                             "small", "bold", "left_margin_16")
  68.         text_buffer.insert_with_tags_by_name(iter, _("Description:\n"),
  69.                                             "small", "bold", "left_margin_16")
  70.         text_buffer.insert_with_tags_by_name(iter, self.__engine_desc.description,
  71.                                             "wrap_text", "left_margin_32")
  72.  
  73.  
  74.     def __create_tags(self, text_buffer):
  75.         text_buffer.create_tag("heading",
  76.                         weight=pango.WEIGHT_BOLD,
  77.                         size = 16 * pango.SCALE)
  78.         text_buffer.create_tag("bold",
  79.                         weight=pango.WEIGHT_BOLD)
  80.         text_buffer.create_tag("italic",
  81.                         style=pango.STYLE_ITALIC)
  82.         text_buffer.create_tag("small",
  83.                         scale=pango.SCALE_SMALL)
  84.         text_buffer.create_tag("gray_foreground",
  85.                         foreground="dark gray")
  86.         text_buffer.create_tag("wrap_text",
  87.                         wrap_mode=gtk.WRAP_WORD)
  88.         text_buffer.create_tag("left_margin_16",
  89.                         left_margin=16)
  90.         text_buffer.create_tag("left_margin_32",
  91.                         left_margin=32)
  92.  
  93.     def __load_icon(self, icon):
  94.         try:
  95.             pixbuf = gdk.pixbuf_new_from_file_at_scale(icon, 48, 48, True)
  96.         except:
  97.             theme = gtk.icon_theme_get_default()
  98.             icon = theme.lookup_icon("ibus", 48, 0)
  99.             if icon == None:
  100.                 icon = theme.lookup_icon("gtk-missing-image", 48, 0)
  101.             pixbuf = icon.load_icon()
  102.         return pixbuf
  103.